#-----------------------------------------------------------
# acmru.pl
# Plugin for Registry Ripper, NTUSER.DAT edition - gets the 
# ACMru values 
#
# Change history
#   20100210
#     [+] Add labels to the subkeys in ACMru to easily understand
#         and quickly understand waht type of search has been done.
#
# References
#   Carvey, H. (2008). Windows Forensic Analisys : The ACMru Key Explain.
#       Retrieved from http://www.regripper.net/RegRipper/Documents/acmru.pdf
# 
# copyright 2008 H. Carvey
# copyright 2010 J.-F. Gingras
#-----------------------------------------------------------
package acmru;
use strict;

my %config = (hive          => "NTUSER\.DAT",
              hasShortDescr => 1,
              hasDescr      => 0,
              hasRefs       => 0,
              osmask        => 22,
              version       => 20080324);

sub getConfig{return %config}
sub getShortDescr {
    return "Gets contents of user's ACMru key";
}
sub getDescr{}
sub getRefs {}
sub getHive {return $config{hive};}
sub getVersion {return $config{version};}

my $VERSION = getVersion();

my %searchsk = (5001 => " (IE - Search from menu bar)",
                5603 => " (Document name)",
                5604 => " (Within a file)",
                5647 => " (Computers or People)");

sub pluginmain {
    my $class = shift;
    my $ntuser = shift;
    ::logMsg("Launching acmru v.".$VERSION);
    my $reg = Parse::Win32Registry->new($ntuser);
    my $root_key = $reg->get_root_key;

    my $key_path = 'Software\\Microsoft\\Search Assistant\\ACMru';
    my $key;
    if ($key = $root_key->get_subkey($key_path)) {
        ::rptMsg("ACMru - Search Assistant");
        ::rptMsg($key_path);
        ::rptMsg("LastWrite Time ".gmtime($key->get_timestamp())." (UTC)");
        my @subkeys = $key->get_list_of_subkeys();
        if (scalar(@subkeys) > 0) {
            foreach my $s (@subkeys) { 
                ::rptMsg($s->get_name().$searchsk{$s->get_name()}." [".gmtime($s->get_timestamp())." (UTC)]");
                my @vals = $s->get_list_of_values();
                my %ac_vals;
                foreach my $v (@vals) {
                    $ac_vals{$v->get_name()} = $v->get_data();
                }
                foreach my $a (sort {$a <=> $b} keys %ac_vals) {
                    ::rptMsg("\t".$a." -> ".$ac_vals{$a});
                }
                ::rptMsg("");
            }
        }
        else {
            ::rptMsg($key_path." has no subkeys.");
            ::logMsg($key_path." has no subkeys.");
        }
    }
    else {
        ::rptMsg($key_path." not found.");
        ::logMsg($key_path." not found.");
    }
}

1;